# detection/train_menu.py
from PyQt5.QtWidgets import QAction
from PyQt5.QtCore import QObject, pyqtSignal

class TrainMenu(QObject):
    """
    训练菜单管理模块
    """
    adjust_params_signal = pyqtSignal()  # 打开参数调整页面
    start_train_signal = pyqtSignal()
    pause_train_signal = pyqtSignal()
    stop_train_signal = pyqtSignal()

    def __init__(self, parent):
        super().__init__(parent)
        self.parent = parent
        self._create_actions()

    def _create_actions(self):
        # 调整参数
        self.adjust_params_action = QAction("调整参数", self.parent)
        self.adjust_params_action.setShortcut("Ctrl+T")
        self.adjust_params_action.triggered.connect(self.adjust_params_signal.emit)

        # 开始训练
        self.start_action = QAction("开始训练", self.parent)
        self.start_action.setShortcut("Ctrl+R")
        self.start_action.triggered.connect(self.start_train_signal.emit)

        # 暂停训练
        self.pause_action = QAction("暂停训练", self.parent)
        self.pause_action.setShortcut("Ctrl+P")
        self.pause_action.triggered.connect(self.pause_train_signal.emit)

        # 停止训练
        self.stop_action = QAction("停止训练", self.parent)
        self.stop_action.setShortcut("Ctrl+E")
        self.stop_action.triggered.connect(self.stop_train_signal.emit)

    def menu_actions(self):
        """
        返回所有菜单项，供主窗口使用
        """
        return [
            self.adjust_params_action,
            self.start_action,
            self.pause_action,
            self.stop_action,
        ]
